#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main() {
    int a, b;
    while (scanf("%d %d", &a, &b) != EOF)
    {
        int arr[a][b];
        int brr[b][a];
        for (int i = 0; i < a; i++)
        {
            for (int j = 0; j < b; j++)
            {
                scanf("%d", &arr[i][j]);
                brr[j][i] = arr[i][j];
            }
        }
        for (int k = 0; k < b; k++)
        {
            for (int m = 0; m < a; m++)
            {
                printf("%d ", brr[k][m]);
            }
            printf("\n");
        }
    }
    return 0;
}